package Demo05172;


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Demo {
    public static void menu() {
        System.out.println("员工管理系统");
        System.out.println("0.退出系统");
        System.out.println("1.添加员工");
        System.out.println("2.查询所有员工");
        System.out.println("3.根据员工姓名查询");
        System.out.println("4.删除员工");
        System.out.println("5.根据员工编号查询");
        System.out.println("6.根据员工编号修改年龄");
        System.out.println("选择操作");
    }

    public static void main(String[] args) {
        TestSet testSet = new TestSet();
        Set<Emp> set = new HashSet<>();

        boolean flag = true;
        while (flag) {
            menu();
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            switch (n) {
                case 0:
                    flag = false;
                    break;
                case 1:
                    System.out.println("输入员工信息");
                    System.out.println("1.输入员工编号");
                    String empNumber = scanner.next();
                    System.out.println("2.输入员工姓名");
                    String empName = scanner.next();
                    System.out.println("3.输入员工年龄");
                    int empAge = scanner.nextInt();

                    Emp addEmp = new Emp(empNumber, empName, empAge);
                    testSet.addEmp(set, addEmp);
                    System.out.println(set);
                    break;
                case 2:
                    testSet.findAllEmp(set);
                    break;
                case 3:
                    System.out.println("输入查询名字");
                    Emp findEmp = testSet.findEmpName(set, scanner.next());
                    System.out.println(findEmp);
                    break;
                case 4:
                    System.out.println("输入要删除的员工编号");
                    String number = scanner.next();
                    testSet.deleteEmpNumber(set, number);
                    break;
                case 5:
                    System.out.println("输入要查询的员工编号");
                    String findNumber = scanner.next();
                    Emp foundEmp = testSet.findEmpNumber(set, findNumber);
                    System.out.println(foundEmp);
                    break;
                case 6:
                    System.out.println("输入修改员工的编号");
                    String updateNumber = scanner.next();
                    Emp updateEmp = testSet.findEmpNumber(set, updateNumber);

                    System.out.println("需要修改的员工年龄");
                    int updateAge = scanner.nextInt();
                    updateEmp.setAge(updateAge);
                    testSet.updateEmpAge(set, updateEmp);
                    break;
            }
        }
    }
}